#ifndef BIT_INCLUDED
#define BIT_INCLUDED
// a set to handle integers
#define T Bit_T
typedef struct T *T;

extern T Bit_new(int length);
// return length of bit set
extern int Bit_length(T set);
// return cnt of 1 in bit set
extern int Bit_count(T set);
extern void Bit_free(T *set);
// if n is in set return 1, else return 0
extern int Bit_get(T set, int n);
extern int Bit_put(T set, int n, int bit);
// clear bit from low to high
extern void Bit_clear(T set, int lo, int hi);
extern void Bit_set(T set, int lo, int hi);
// reverse bit from low to high
extern void Bit_not(T set, int lo, int hi);
// if t contains s, return 1 else 0; locate
extern int Bit_lt(T s, T t);
// equal
extern int Bit_eq(T s, T t);
extern int Bit_leq(T s, T t);
extern void Bit_map(T set,
                    void apply(int n, int bit, void *cl), void *cl);

// s + t  s or t
extern T Bit_union(T s, T t);
// s*t s and t
extern T Bit_inter(T s, T t);
// s-t  s and ~t
extern T Bit_minus(T s, T t);
// s/t  xor
extern T Bit_diff(T s, T t);
#undef T
#endif